<?php
// +----------------------------
// | Created by PhpStorm
// +----------------------------
// | Author: YnnSon
// +----------------------------
namespace app\api\model;

/**
 * Banner图
 * Class Ad
 * @package app\api\model
 */
class Ad extends BaseModel
{
    /**
     * @Desc 为图片添加URL前缀
     *
     * @param $value
     *
     * @return string
     */
    protected function getAdCodeAttr($value)
    {
        return $this->addWebUrlPrefixToImage($value);
    }

    /**
     * @Desc 获取banner图
     * @return Ad[]|false
     */
    public static function getAd()
    {
        $ad = (new self)->field('ad_code')->where('is_delete', '=', '0')->where('enabled', '=', '1')->order('orderby')->select();
        return $ad->toArray();
    }
}